package com.example.threaddemo.controller;

import com.example.threaddemo.util.apiResp.ApiResp;
import com.example.threaddemo.util.apiResp.BaseEnumError;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author Boolean
 * @Date 2021/3/22 16:46
 * @Version 1.0
 */

@RestController
public class TestController {

    @RequestMapping("/")
    public Object i(HttpServletRequest request) {
        Map<String, Object> res = new HashMap<String, Object>();
        res.put("ip:", request.getScheme() + "://" + request.getServerName()
                + ":" + request.getServerPort() + request.getRequestURI());
        return res;

    }

    @GetMapping("/test1")
    public ApiResp test1() {

        return ApiResp.retOK("Hello World");
    }

    @GetMapping("/test2")
    public ApiResp test2() {

        return ApiResp.retFail(BaseEnumError.SYSTEM_NO_LOGIN);
    }
}
